<?php

namespace App\Http\Resources\Course;

use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Carbon;

class CourseOrderResource extends JsonResource
{
    public function toArray($request)
    {
        return [
            'id'               => $this->id,
            'order_sn'         => $this->order_sn,
            'pay_sn'           => $this->pay_sn,
            'pay_amount'       => fen_to_yuan($this->pay_amount),
            'pay_time'         => date('Y-m-d H:i:s', $this->pay_time),
            'course_id'        => $this->course_id,
            'course_name'      => $this->course_name,
            'course_cover'     => $this->course_cover,
            'course_price'     => fen_to_yuan($this->course_price),
            'course_vip_price' => fen_to_yuan($this->course_vip_price),
            'created_at'       => Carbon::parse($this->created_at)->format('Y-m-d H:i:s'),
        ];
    }
}
